USE master;
GO

DBCC DROPCLEANBUFFERS;
GO
SET STATISTICS TIME ON;

-- check the AdventureWorks database using PHYSICAL and LOGICAL
DBCC CHECKDB (N'AdventureWorks') WITH NO_INFOMSGS;

SET STATISTICS TIME OFF;
GO
-- CPU time = 11562 ms,  elapsed time = 5083 ms.

DBCC DROPCLEANBUFFERS;
GO
SET STATISTICS TIME ON;

-- check the AdventureWorks database using PHYSICAL_ONLY
DBCC CHECKDB (N'AdventureWorks') WITH NO_INFOMSGS, PHYSICAL_ONLY;

SET STATISTICS TIME OFF;
GO
-- CPU time = 2719 ms,  elapsed time = 1265 ms.

USE AdventureWorks;
GO

DBCC DROPCLEANBUFFERS;
GO
SET STATISTICS TIME ON;

-- check the HumanResources.Employee table in the AdventureWorks database using PHYSICAL_ONLY
DBCC CHECKTABLE ('HumanResources.Employee') WITH PHYSICAL_ONLY;

-- CPU time = 32 ms,  elapsed time = 106 ms.

DBCC DROPCLEANBUFFERS;
GO

-- check the AK_Product_Name index in the AdventureWork's table Production.Product
DECLARE @index_id int =
	(SELECT index_id FROM sys.indexes
		WHERE object_id = OBJECT_ID('Production.Product')
			AND name = 'AK_Product_Name');
DBCC CHECKTABLE ('Production.Product', @index_id);

SET STATISTICS TIME OFF;
GO
-- CPU time = 16 ms,  elapsed time = 96 ms.

-- when did DBCC CHECKDB last run successfully?
-- TF3604 redirects the DBCC PAGE output to your console
DBCC TRACEON (3604);
GO

-- page 9 is the boot page
/*
You need to look for the dbi_dbccLastKnownGood field.
That was the last time that DBCC CHECKDB ran without finding any corruptions.
*/
DBCC PAGE (AdventureWorks, 1, 9, 3);
GO

DBCC TRACEOFF (3604);
GO